package com.dhb.base.web;


import com.dhb.base.bean.ResultBean;
import com.dhb.base.entity.ElectricEntity;
import com.dhb.base.service.ElectricService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

@Api(tags = {"demo"})
@RestController
@RequestMapping("/demo")
public class ElectricController {

    @Resource
    ElectricService electricService;


    @Value("${server.port}")
    String port;

    @PostMapping("/addElectricEntity")
    public ElectricEntity addElectricEntity(@RequestBody ElectricEntity electricEntity) throws UnsupportedEncodingException {
        electricService.addElectric(electricEntity);
        return electricEntity;
    }

    @GetMapping("/findAllElectric")
    public ResultBean<List<ElectricEntity>> findAllElectric() throws UnsupportedEncodingException {

        return new ResultBean<>(electricService.findAllElectric());
    }

}
